package me.cat.listdemo.learn;

import java.util.ArrayList;

public class ArrayListDemo1 {
    public static void main(String[] args) {
        //创建一个集合
        ArrayList<String> list = new ArrayList<>();
        //添加元素
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        //System.out.println(list);
        //删除元素
        //boolean result = list.remove("aaa");
        //System.out.println(result);
       /* String str = list.remove(2);
        System.out.println(str);*/
        //修改元素
        String result = list.set(1,"ddd");
        System.out.println(result);
        System.out.println(list);
        //查询元素
        String s = list.get(0);
        System.out.println(s);
        //遍历
        for (int i = 0; i < list.size(); i++) {
            String str = list.get(i);
            System.out.println(str);
        }
    }
}
